package object;

import gameBasics.GameModel;
import gameBasics.GameObject;
import gameBasics.ResourceManager;
import java.awt.*;

public class CommandPost extends GameObject {

    public final int WIDTH = ResourceManager.commandPost.getWidth();    //指挥所的宽度
    public final int HEIGHT = ResourceManager.commandPost.getHeight();  //指挥所的高度
    private boolean livingState = true;                                 //指挥所的存活状态

    public CommandPost(int x, int y){
        this.x = x;
        this.y = y;

        rectangle.x = this.x;
        rectangle.y = this.y;
        rectangle.width = this.WIDTH;
        rectangle.height = this.HEIGHT;

        GameModel.getInstance().addGameObject(this);
    }

    /**
     * 绘制指挥所
     * @param graphics 画笔对象
     */
    @Override
    public void paint(Graphics graphics) {
        if(!livingState) GameModel.getInstance().removeGameObject(this);

        graphics.drawImage(ResourceManager.commandPost,x,y,null);
    }

    @Override
    public int getWidth() {
        return WIDTH;
    }

    @Override
    public int getHeight() {
        return HEIGHT;
    }

    /**
     * 指挥所消亡
     */
    public void die() {
        this.livingState = false;
    }

}
